﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.Util;
using Com.CMS263.BLL;

namespace Com.CMS263.Web.manage.MyStyle
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        MyStyleBLL bll = new MyStyleBLL();
        public int level = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["level"])) 
            {
                level = int.Parse(Request["level"]);
                this.hdfLevel.Value = level.ToString();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string title = null;
            int price = 0;
           
            string dvdNum = null;
            string album = null;
            int clothid = 0;
            int demId = 0;
            int xtId = 0;
            int gift = 0;
            int winId=0;
            string description = null;

           
            if (!string.IsNullOrEmpty(this.price.Text))
            {
                try
                {
                    price = int.Parse(this.price.Text);
                }
                catch (Exception ex)
                {

                    StringUtil.Alert("请填写正确的价格", "-1");
                }
            }
            else
            {
                StringUtil.Alert("请填写价格", "-1");
            }

           

            if (!string.IsNullOrEmpty(this.album.Text))
            {
                album = StringUtil.checkStr(this.album.Text);
            }
            else
            {
                StringUtil.Alert("请填写相册的描述", "-1");
            }
           
            
             if (!string.IsNullOrEmpty(this.dvdNum.Text))
             {
                 dvdNum = StringUtil.checkStr(this.dvdNum.Text);
             }
             else
             {
                 StringUtil.Alert("赠送dvd得描述", "-1");
             }


             if (!string.IsNullOrEmpty(this.clothId.Text))
             {
                 try
                 {
                     clothid = int.Parse(this.clothId.Text);
                 }
                 catch (Exception ex)
                 {

                     StringUtil.Alert("请填写正确的编号", "-1");
                 }
             }
             else
             {
                 StringUtil.Alert("请填写婚纱编号", "-1");
             }


             if (!string.IsNullOrEmpty(this.demId.Text))
             {
                 try
                 {
                     demId = int.Parse(this.demId.Text);
                 }
                 catch (Exception ex)
                 {

                     StringUtil.Alert("请填写正确的珠宝编号", "-1");
                 }
             }
             else
             {
                 StringUtil.Alert("请填写珠宝编号", "-1");
             }

             if (!string.IsNullOrEmpty(this.xtId.Text))
             {
                 try
                 {
                     xtId = int.Parse(this.xtId.Text);
                 }
                 catch (Exception ex)
                 {

                     StringUtil.Alert("请填写正确的喜帖编号", "-1");
                 }
             }
             else
             {
                 StringUtil.Alert("请填写喜帖编号", "-1");
             }

             if (!string.IsNullOrEmpty(this.gift.Text))
             {
                 try
                 {
                     gift = int.Parse(this.gift.Text);
                 }
                 catch (Exception ex)
                 {

                     StringUtil.Alert("请填写正确的礼品编号", "-1");
                 }
             }
             else
             {
                 StringUtil.Alert("请填写礼物编号", "-1");
             }

             if (!string.IsNullOrEmpty(this.winId.Text))
             {
                 try
                 {
                     winId = int.Parse(this.winId.Text);
                 }
                 catch (Exception ex)
                 {

                     StringUtil.Alert("请填写正确的喜酒编号", "-1");
                 }
             }
             else
             {
                 StringUtil.Alert("请填写喜酒编号", "-1");
             }

             if (!string.IsNullOrEmpty(this.desc.Text))
             {
                 description = StringUtil.checkStr(this.desc.Text);
             }
             else
             {
                 StringUtil.Alert("请填写风格的描述", "-1");
             }

             Com.CMS263.PO.MyStyle style = new Com.CMS263.PO.MyStyle();
             style.Price = price;
             style.Stylelevel =int.Parse( this.hdfLevel.Value);
             style.Title = " ";
             style.WinId = winId;
             style.XtId = xtId;
             style.Gift = gift;
             style.Album = album;
             style.DvdNum = dvdNum;
             style.DemId = demId;
             style.ClothId = clothid;
             style.Album = album;
             style.Description = description;
             style.AddDate = DateTime.Now;
             style.Ordernum = int.Parse(this.orderNum.Text);

             if (bll.Add(style))
             {
                 StringUtil.Alert("添加成功", "View.aspx?level="+this.hdfLevel.Value);
             }
             else 
             {
                 StringUtil.Alert("添加失败，请重试","-1");
             }
            
        }
    }
}
